<html lang="en"> 
<head> 
    <meta charset="UTF-8"> 
    <script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js">
    </script>
    <title>ajax</title> 
</head> 
<body> 
    <input type="text" id="biaodan"/>
    <button id="click2">提交</button> 
    <button id="click1">查看新消息</button>
    <div id="content"></div>
    <script> 
    var sending=false; 
    $(function(){ 
        $("#click1").click(function(){ 
            $.ajax({ 
                type:"POST", 
                url:"server.php", 
                timeout:0, 
                beforeSend:function(){ 
                    if (sending) { 
                        return false; 
                    } 
                    sending = true; 
                }, 
                data:{
                    // message:"hello,world!"
                }, 
                success:function(data){ 
                    $("#content").append(data+"<br>");
                }, 
                error:function(data){ 
                    ; 
                }, 
                complete:function(){ 
                    sending=false; 
                    $("#click1").click(); 
                } 
            }); 
        }); 

        $("#click2").click(function(){ 
            $.ajax({ 
                type:"POST", 
                url:"server.php", 
                timeout:0,  
                data:{
                    message:$("#biaodan").val()
                }
            }); 
        });
    }); 
    </script> 
</body> 
</html> 